using UnityEngine;

using System.Collections;

public class radialBlur : PostEffectsBase
{
    public Shader radialBlurShader;
    private Material radialBlurMaterial = null;
    public Material material{
        get {
            radialBlurMaterial = CheckShaderAndCreateMaterial(radialBlurShader, radialBlurMaterial);
            return radialBlurMaterial;
        }
    }

    [Range(1, 8)]
    public int downSample = 2;

    [Range(0.0f, 0.1f)]
    public float blurFactor = 0.5f;

    [Range(1, 10)]
    public int blurNum = 5;

    public Vector2 blurCenter = new Vector2(0.5f, 0.5f);

    void OnRenderImage (RenderTexture src, RenderTexture dest) {
        if (material != null) {
            material.SetVector("_blurCenter", blurCenter);
            material.SetFloat("_blurFactor", blurFactor);
            material.SetInt("_blurNum", blurNum);

            Graphics.Blit(src, dest, material);
        }
        else{
            Graphics.Blit(src, dest);
        }
    }
}
